<template>
  <div id="app" :style="{'min-height': height}">
    <router-view />
    <!-- 加载loading -->
    <div v-if="$store.state.loading" class="cenCen van-loading-box">
      <van-loading type="circular" size="66px" color="white" />
      <span v-if="$store.state.loadingText" style="margin-left:10px">{{$store.state.loadingText}}</span>
    </div>
  </div>
</template>

<script>
import router from "./router";

export default {
  // 监听,当路由发生变化的时候执行
  watch: {
    $route: {
      handler(val, oldVal) {
        this.$store.state.loadingText = "";
      },
      // 深度观察监听
      deep: true
    }
  },
  name: "App",
  data() {
    return {
      height: ""
    };
  },
  mounted() {
    this.height = window.innerHeight + "px";
    router.afterEach(() => {
      this.height = window.innerHeight + "px";
    });
  }
};
</script>

<style>
#app {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #eeeeee;
}
</style>
